<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子16-JS进阶（三）</title>
    </head>
    <body>
        <pre>
            <code>
                    // 例子16

                    var str1 = 'aaa';
                    var str2 = 'aaab';
                    var pattern1 = /a+/;
                    var pattern2 = /a+?/;
                    var pattern3 = /a+b/;
                    var pattern4 = /a+?b/;
                    str1.match(pattern1); // ['aaa'], 匹配后继续匹配，取最长的匹配
                    str1.match(pattern2); // ['a'], 匹配后不再继续匹配，取最短匹配
                    str2.match(pattern3); // ['aaab']
                    str2.match(pattern4); // ['aaab'], 这里匹配到第三个a时才匹配到b，所以结果和前面一个相同
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/16.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>
</html>